package cn.com.dhc.danlu.delegate.delegate.coupon;

import java.util.List;

import cn.com.dhc.danlu.delegate.callback.ICouponListView;
import cn.com.dhc.danlu.delegate.delegate.list.BaseListDataDelegate;
import cn.com.dhc.danlu.dlware.OperatorUtils;
import cn.com.hd.mall.web.webservices.entity.BaseResponse;
import cn.com.hd.mall.web.webservices.entity.freedom.request.coupon.GetCouponListReq;
import cn.com.hd.mall.web.webservices.entity.freedom.response.coupon.GetCouponListResponse;
import rx.Observable;

import static cn.com.dhc.danlu.dlware.global.DanluApplication.agent;

/**
 * User: Geek_Soledad(wuhaiyang@danlu.com)
 * Date: 2016-09-27
 * Time: 15:20
 * Description: .....
 */
public class DealersCouponUsedDelegate extends BaseListDataDelegate<ICouponListView> {

    @Override
    protected Observable createRequestObservable(int page) {
        GetCouponListReq req = (GetCouponListReq) mViewBridge.createFetchReqParams();
        req.setRows(mPageSize);
        req.setPage(page);
        req.setToken(agent.getToken());
        return agent.getApi().getCouponList(req).compose(OperatorUtils.<GetCouponListResponse>defaultSchedulers());
    }

    @Override
    protected List excavateList(BaseResponse model) {
        GetCouponListResponse res = (GetCouponListResponse) model;
        return res.getCouponList();
    }
}
